/**
 * 
 */

package com.pp.admin.main.client.tab;

import com.google.gwt.event.dom.client.ClickHandler;
import com.pp.admin.common.client.helper.AdminButton;
import com.pp.admin.common.client.helper.Resource;
import com.pp.admin.main.client.common.CrudOnListPage;

/**
 * @author pandurang
 */
public class CrudOnUserListPage extends CrudOnListPage {
	
	private AdminButton	disable		= null;
	
	private AdminButton	activate	= null;
	
	/**
	 * 
	 */
	public CrudOnUserListPage() {

		super();
		disable = new AdminButton( myConstants.disable(), Resource.DISABLE_IMG_URL );
		activate = new AdminButton( myConstants.activate(), Resource.OK_IMG_URL );
		add( disable );
		add( activate );
	}
	
	public void addDisableClickHandler( ClickHandler handler ) {

		disable.addClickHandler( handler );
	}
	
	public void addActivateClickHandler( ClickHandler handler ) {

		activate.addClickHandler( handler );
	}
	
	public void disableDisableAction() {

		disable.setEnabled( false );
		disable.setImageURL( Resource.DISABLE_DISABLE_IMG_URL );
	}
	
	public void enableDisableAction() {

		disable.setImageURL( Resource.DISABLE_IMG_URL );
		disable.setEnabled( true );
	}
	
	public void disableActivateAction() {

		activate.setImageURL( Resource.DISABLE_OK_IMG_URL );
		activate.setEnabled( false );
	}
	
	public void enableActivateAction() {

		activate.setImageURL( Resource.OK_IMG_URL );
		activate.setEnabled( true );
	}
	
	public boolean isDisableOn() {

		return disable.isEnabled();
	}
	
	public boolean isActivateOn() {

		return activate.isEnabled();
	}
	
	@Override
	public void refreshState() {

		super.refreshState();
		if ( !disable.isEnabled() ) {
			enableDisableAction();
		}
		
		if ( !activate.isEnabled() ) {
			enableActivateAction();
		}
	}
}
